package com.example.userserver.controller;

import com.example.common.result.R;
import com.example.userserver.service.IUserService;
import com.example.userserver.vo.UserVO;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author benjamin_5
 * @Description 用户接口
 * @date 2023/2/23
 */
@RestController
@RequestMapping("user")
@AllArgsConstructor
public class UserController {

    private final IUserService userService;

    /**
     * 保存
     * @param user
     * @return
     */
    @PostMapping("save")
    public R save(@RequestBody UserVO user){
        return userService.save(user);
    }

    /**
     * 保存
     * @param user
     * @return
     */
    @PostMapping("save2")
    public R save2(@RequestBody UserVO user){
        return userService.save2(user);
    }

    /**
     * 保存
     * @param user
     * @return
     */
    @PostMapping("save3")
    public R save3(@RequestBody UserVO user){
        return userService.save3(user);
    }


    /**
     * 查询
     * @param userName
     * @return
     */
    @GetMapping("getByUserName")
    public R getByUserName(@RequestParam String userName){
        return R.data(userService.getCacheByUserName(userName));
    }



}
